#!/usr/bin/python -S
"""
fly_test.py: Tests for fly.py
"""

import os
import unittest

import fly  # module under test


class FlyTest(unittest.TestCase):

  def testPipes(self):
    # TODO: This test depends on real files.
    result = fly.GetWorkerState('fly-state/curl')
    # This fails if the process isn't up!
    assert result, result
    pid, in_fd, out_fd, err_fd = result
    print 'Writing hi'
    os.write(in_fd, 'hi\n')
    #print 'reading'
    #bytes = os.read(resp, 1)
    #print bytes

  def testIsRunning(self):
    print fly.IsRunning(0)
    print fly.IsRunning(9999)


if __name__ == '__main__':
  unittest.main()
